package com.doubao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.doubao.entity.SmartDeviceTagRelation;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;

@Mapper
public interface SmartDeviceTagRelationMapper extends BaseMapper<SmartDeviceTagRelation> {

    /**
     * 删除智能体的所有标签关联
     */
    @Delete("DELETE FROM smart_device_tag_relation WHERE device_id = #{deviceId}")
    int deleteByDeviceId(@Param("deviceId") Long deviceId);

    /**
     * 删除指定智能体的指定标签关联
     */
    @Delete("DELETE FROM smart_device_tag_relation " +
            "WHERE device_id = #{deviceId} AND tag_id = #{tagId}")
    int deleteByDeviceAndTag(@Param("deviceId") Long deviceId, @Param("tagId") Long tagId);
}
